package controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.Desenvolvedor;
import model.Equipe;
import model.Projeto;
import model.Tarefa;

/**
 * Servlet implementation class incluirTarefa
 */
public class IncluirTarefa extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public IncluirTarefa() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// obter dados do formulario
		String titulo = request.getParameter("titulo");
		int prazoExecucao = Integer.parseInt(request.getParameter("prazoExecucao"));
		String detalhes = request.getParameter("detalhes");
		Desenvolvedor responsavel = Equipe.getDesenvolvedor(request.getParameter("responsavel"));
		boolean urgente = (request.getParameter("urgente") != null)?true:false;
        // Criar tarefa
		Tarefa tarefa = new Tarefa(titulo,prazoExecucao,detalhes,responsavel,urgente);
		// Adicionar ao projeto
		Projeto.getProjeto().incluirTarefa(tarefa);
		response.sendRedirect("index.jsp");
	}
}
